package Lab1;

import java.text.NumberFormat;
import java.util.Locale;
import java.util.Scanner;

public class Account {
	private long stk;
	private String ttk;
	private double sotien;
	private final float laisuat = 0.02f;
	//ham tao mac dinh
	public Account(){
		this.stk = 0;
		this.ttk = null;
		this.sotien = 0;
	}
	public Account(long stk, String ttk, double sotien){
		this.stk = stk;
		this.ttk = ttk;
		this.sotien = sotien;
	}
	public Account(long stk, String ttk){
		this.stk = stk;
		this.ttk = ttk;
		this.sotien = 100;
	}
	public long getStk() {
		return stk;
	}
	public void setStk(long stk) {
		this.stk = stk;
	}
	public String getTtk(){
		return ttk;
	}
	public void setTtk(){
		this.ttk = ttk;
	}	
	public double getSotien() {
		return sotien;
	}
	public void setSotien(double sotien) {
		this.sotien = sotien;
	}
	@Override
	public String toString() {
		Locale loc = Locale.getDefault();
		NumberFormat nf = NumberFormat.getCurrencyInstance(loc);
		return "Account : /n So tai khoan : " + getStk() + "/n Ten tai khoan: " + getTtk() + "/n So tien : " + nf.format(getSotien());
	}
	public void naptien(double tiennap){
		//System.out.println("Nhap so tien can nap ");
		//Scanner sc = new Scanner(System.in);
		//tiennap = sc.nextDouble();
		if(tiennap < 0){
			System.out.println("Nhap sai roi kia");
		}
		else{
			this.sotien = getSotien() + tiennap;
		}
		System.out.println("So tien trong tai khoan la: " +getSotien());
		
	}
	public void ruttien(double tienrut){
		//System.out.println("Nhap so tien can rut ");
		//Scanner sc = new Scanner(System.in);
		//tienrut = sc.nextDouble();
		if(this.sotien <= 0){
			System.out.println("Ko co tien!!!");
		}
		else{
			double phirut = 0.02* (this.sotien);
			this.sotien = getSotien() - (tienrut + phirut);			
		}
		System.out.println("So tien trong tai khoan la: " + getSotien());
	}
	
	public void chuyentien(Account a,long stk,String ttk,double tienchuyen){
		a = new Account();
		this.sotien = getSotien() - tienchuyen;
		a.sotien += tienchuyen; 
		System.out.println("So tien trong tai khoan la: " + getSotien());
	}
	
	public static void main(String [] args){
		Account a1 = new Account();
		Account a2 = new Account();
		a1.naptien(900);
		a1.ruttien(200);
		a1.chuyentien(a2,123,"H",200);
		
	}
	
}